<!DOCTYPE html>
<html>
    <head>
        <title>Admin Planners!</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <script src="{{base_url()}}syslib/MyScript/jquery-1.7.2.js"></script>
        <script src="{{base_url()}}syslib/MyScript/vadilation.js"></script>
        <link href="{{base_url()}}syslib/syscss/sysstyle.css" type="text/css" rel="stylesheet"/>
        <link href="{{base_url()}}syslib/syscss/bubble.css" type="text/css" rel="stylesheet"/>
        <link href="{{base_url()}}syslib/syscss/24_grid_960.css" type="text/css" rel="stylesheet"/>
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-twitter/tip-twitter.css" type="text/css" />
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-yellow/tip-yellow.css" type="text/css" />
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-violet/tip-violet.css" type="text/css" />
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-darkgray/tip-darkgray.css" type="text/css" />
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-skyblue/tip-skyblue.css" type="text/css" />
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-yellowsimple/tip-yellowsimple.css" type="text/css" />
        <link rel="stylesheet" href="{{base_url()}}syslib/poshytip-1.1/src/tip-green/tip-green.css" type="text/css" />
    </head>
    <body style="overflow-y: scroll;">
        {{include file='../sys/01_notice.tpl'}}
        {{include file='../sys/02_script.tpl'}}
        <div style="min-width: 960px;max-width: 1366px">
            <div style="padding: 100px">
                <div class="pl20 pr20 lh16 pt12 pb12">
                    APanel 1.1.9 &copy; 2013.<br/>
                    <a href="{{base_url()}}admin-planners/accessdenied">APanel 1.x.x &copy; 2008 - 2012.</a><br/>
                    
                </div>
                <div class="grid_4" style="background-color: #EBEFF9;border: solid 1px #C9D7F1;">
                    <div class="pt4 pl4 pr4 pb4">
                        <div class="OAuths">
                            <div class="OAumenu">
                                <div class="C1">
                                    Oauth 2.0
                                </div>
                                <span class="C2"></span>
                            </div>
                            <div class="OAumenu">
                                <div class="C1">
                                    Google APIs
                                </div>
                                <span class="C2"></span>
                            </div>
                            <div class="OAumenu active">
                                <div class="C1">
                                    Authorized API Access
                                </div>
                                <span class="C2"></span>
                            </div>
                            <div class="OAumenu">
                                <div class="C1">
                                    APanel 1.1.9
                                </div>
                                <span class="C2"></span>
                            </div>
                            <div class="OAumenu">
                                <div class="C1">
                                    Web Applications
                                </div>
                                <span class="C2"></span>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                </div>

                {{if isset($Data["authUrl"])}} 
                    <div class="grid_x pl20">
                        <div class="bdccc gadiend-white">
                            <div class="bdbccc lh28 pl20 pt2 pb2">Login with Google API</div>
                            <div class="pt20 pb20 pl20 pr20">
                                <a href="{{$Data["authUrl"]}}">
                                    <img src="{{base_url()}}syslib/sysimages/64/gmail.png"/>
                                    <img src="{{base_url()}}syslib/sysimages/64/google.png"/>
                                    <img src="{{base_url()}}syslib/sysimages/64/google_color.png"/>
                                </a>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                {{/if}}
                {{if isset($Data["user"])}}       
                    <div class="grid_x pl20">
                        <div class="bdccc gadiend-white">
                            <div class="bdbccc lh28 pl20 pt2 pb2">Google Account</div>
                            <div class="pt8 pb16 pl16 pr16 grid_x bdrccc">
                                <img class="grid_2" src="{{$Data["user"]->Picture}}"/>
                            </div>
                            <div class="pt8 pb0 pl16 pr16 grid_x lh16">
                                <form action="{{base_url("sys/excution/nothing")}}" 
                                name="frmlogin"
                                target="integration_asynchronous"
                                onsubmit="login()"
                                method="post">
                                <table>
                                    <tr>
                                        <td>Name</td>
                                        <td><tt>{{$Data["user"]->Name}}</tt></td>
                                    </tr>
                                    <tr>
                                        <td>Email</td>
                                        <td><tt>{{$Data["user"]->Email}}</tt></td>
                                    </tr>
                                    {{if isset($_SESSION["ADP"]["USER"])}}
                                        <tr>
                                            <td colspan="2" class="tac">
                                                <a href="{{base_url('OAuth/home/logout')}}">Not sync</a>
                                                &nbsp;&nbsp;&nbsp;
                                                <a href="{{base_url('APanel')}}">Admin Planners</a>
                                            </td>
                                        </tr>
                                    {{else}}
                                        <tr>
                                            <td>Secret Key</td>
                                            <td><input type="password" id="txtpassword" name="txtpassword" class="classic-input"/></td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" class="tac">
                                                <a class="a" href="{{base_url('OAuth/home/logout')}}">Not sync</a>
                                                &nbsp;&nbsp;&nbsp;
                                                <span onclick="login()" class="a">Login</a>
                                            </td>
                                        </tr>
                                    {{/if}}
                                </table>
                                </form>
                            </div>
                            <div class="clear"></div>
                        </div>
                        <div class="clear"></div>
                    </div>
                {{else}}
                    <div class="grid_x pl20">
                        <div class="bdccc gadiend-white">
                            <div class="bdbccc lh28 pl20 pt2 pb2">Login with Deal Account</div>
                            <div class="pt12 pb12 pl20 pr20">
                                <form action="{{base_url("sys/excution/nothing")}}" 
                                name="frmlogin"
                                target="integration_asynchronous"
                                onsubmit="login2()"
                                autocomplete="true"
                                method="post">
                                    <div class="pb4">
                                        <input type="text" id="txtu2" placeholder="Tên đăng nhập" required="required" class="classic-input w160px"/>
                                    </div>
                                    <div class="pb4">
                                        <input type="password" id="txtp2" placeholder="Mật khẩu" required="required" class="classic-input w160px"/>
                                    </div>
                                    <button type="submit" class="classic-button"><span>Login</span></button>
                                </form>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                {{/if}}
            </div>
            <div class="clear"></div>
            <div class="pt20 pl100 pr100">
                {{if isset($Data["user"])}}
                {{foreach $Data["Accs"] as $ac}}
                    <div class="grid_x pl4 pb4">
                        <div class="bdccc gadiend-white">
                            <div class="bdbccc lh20 pl20 pt2 pb2">
                                {{$ac->AuthorityName}}
                            </div>
                            <div class="pt4 pb4 pl4 pr4 grid_x bdrccc">
                                <img class="grid_1" src="{{$ac->Picture}}"/>
                            </div>
                            <div class="pt4 pb4 pl4 pr4 grid_x lh16">
                                <table>
                                    <tr>
                                        <td class="pr12">Name</td>
                                        <td>{{$ac->Name}}</td>
                                    </tr>
                                    <tr>
                                        <td class="pr12">Email</td>
                                        <td>
                                            {{if isset($Data["user"])}}
                                                {{if $Data["user"]->Position>=$ac->Position}}
                                                    {{$ac->Email}}
                                                {{else}}
                                                    ********@gmail.com
                                                {{/if}}
                                            {{else}}
                                                ********@gmail.com
                                            {{/if}}
                                        </td>
                                    </tr>

                                </table>
                            </div>
                            <div class="clear"></div>
                        </div>
                        <div class="clear"></div>
                    </div>
                {{/foreach}}
                {{/if}}
            </div>
        </div>
        <style>
            table {
                display: inline-block;
                border-collapse: collapse;
            }
            th, td {
                display: table-cell;
            }
            tr {
                display: table-row;
            }
        </style>
        <script>
            function login(){
                if(isrunning) return;
                if(!_FcheckFilled($("#txtpassword").val())){
                    $("#txtpassword").focus();
                    return;
                }
                var url = "{{base_url()}}OAuth/home/login/940cc81cec5c7e119162e62bd57710f0"
                var data={
                    password : $("#txtpassword").val()
                }
                isrunning=true;
                jqxAjax(url,data,function(result){
                    isrunning=false;
                    try{
                        if(result.code<0){
                            tipMessage(result.msg);
                        }else{
                            tipMessage(result.msg);
                            setTimeout(function(){
                                window.location.href="{{base_url()}}APanel";
                            },3000);
                        }
                    }catch(e){                                    
                        tipMessage(e.message);
                    }
                });
            }
            function login2(){
                if(isrunning) return;
                if(!_FcheckFilled($("#txtu2").val())){
                    $("#txtu2").focus();
                    return;
                }
                if(!_FcheckFilled($("#txtp2").val())){
                    $("#txtp2").focus();
                    return;
                }
                var url = "{{base_url()}}OAuth/home/login/940cc81cec5c7e119162e62bd57710f0"
                var data={
                    username : $("#txtu2").val(),
                    password : $("#txtp2").val()
                }
                isrunning=true;
                jqxAjax(url,data,function(result){
                    isrunning=false;
                    try{
                        if(result.code<0){
                            tipMessage(result.msg);
                        }else{
                            tipMessage(result.msg);
                            setTimeout(function(){
                                window.location.href="{{base_url()}}APanel";
                            },3000);
                        }
                    }catch(e){                                    
                        tipMessage(e.message);
                    }
                });
            }
        </script>
    </body>
</html>